<?php
/***
	好习惯和坏习惯模型。
**/
class Behave_model extends CI_Model {
	
	public function __construct() {
		$this->load->database();
	}
	//返回好习惯
	public function get_good() {
		
		$query = $this->db->get_where('behave', array('type' => 'good'));
		return $query->result_array();
		
	}
	
	//返回坏习惯
	public function get_bad() {
		
		$query = $this->db->get_where('behave', array('type' => 'bad'));
		return $query->result_array();
		
	}
	
	//新增
	public function add () {

		
		$data = array(
			'des' => $this->input->post('des'),
			'type' => $this->input->post('type')
			
		);
		$this->db->insert('behave', $data);
	}
	
	//删除
	public function del ($id) {
		$this->db->delete('behave', array('id' => $id));
		
	}
	
	
	

}
